/* 
  @component 全部页面的mixin
*/
export default {
  data() {
    return {};
  },
  computed: {
    indicator: {
      get() {
        return this.$store.state.indicator;
      },
      set(value) {
        this.$store.commit("SET_INDICATOR", {
          value,
        });
      },
    },
    pageTransition() {
      return this.$store.state.pageTransition;
    },
  },
  methods: {
    // 当页面显示时
    onPageView() {},
    // 当页面离开时
    onPageLeave() {},
    // 当页面刷新时
    onPageRefresh() {},
    init() {},
  },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      vm.onPageView();
    });
  },
  beforeRouteLeave(to, from, next) {
    this.onPageLeave();
    let toDepth = to.path.split("/").length;
    let fromDepth = from.path.split("/").length;
    //返回时
    if (toDepth < fromDepth) {
      //当此页面缓存切返回到上一页面时， 销毁此页面
      this.$destroy();
    }
    next();
  },
  created() {
    this.init();
  },
};